package exception;
/**
 * finally笔试面试题
 * */
public class FinallyDemo3 {
    public static void main(String[] args) {
        System.out.println(
                test("0")+","+test(null)+","+test("")//3,3,3
                //若无finally'0'-'0'=0,空指针 1,下标越界 2
        );
    }
    public static int test(String str){//int a(临时变量名)
        try {
            return str.charAt(0)-'0';
        }
        catch (NullPointerException e){
            return 1;
        }
        catch (Exception e){
            return 2;
        }
        finally {
            return 3;
        }
    }
}
